<?php

declare(strict_types=1);
/**
 * This file is part of habo_new_media.
 *
 * @link     https://www.berlen.cn/
 * @contact  tech@berlen.cn
 * @license  http://gitlab.rehou.cn/habo/habo_new_media/-/blob/master/README.md
 */
namespace app\service\fetch;

use app\service\fetch\qq\MongoPicService;
use app\service\fetch\qq\MongoVideoService;

class QqFetchService extends FetchService
{
    /**
     * mongo拉取视频增量列表.
     * @param string $advertiserId 账户id
     */
    public static function fetchMongoVideoList(string $advertiserId = ''): bool
    {
        $key = MongoVideoService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = MongoVideoService::getVideo($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

    /**
     * mongo拉取图片列表.
     * @param string $advertiserId 账户id
     */
    public static function fetchMongoPicList(string $advertiserId = ''): bool
    {
        $key = MongoPicService::getFetchKey($advertiserId);
        if (self::lock($key, $advertiserId)) {
            $res = MongoPicService::getPic($advertiserId);
            self::unlock($key);
            return $res;
        }
        return true;
    }

}
